<template>
	<view class="content">
		<view style="padding: 15px;">
			<person-information></person-information>
		</view>
		<tabs-active @checkHandel="checkHandel" :checkIndex="indexc"></tabs-active>
		<view style="padding-bottom: 100px;"  v-if="indexc==0">
			<price-item :list="priceList" @handelClick="priceHandel"></price-item>
		</view>
		<!-- <price-item :list="pricedata" v-else></price-item> -->
		<!-- Submit X Post 弹窗 start -->
		<uni-popup
			width="100%"
			ref="popup"
			 background-color="#1B2025"
			 bottom
			 type="bottom"
			 borderRadius="10px 10px 0 0"
			 @change="change">
			<view class="popup-content">
				 <view class="title">
				 	<view class="title_name">Submit X Post</view>
					<view class="title_icon"  @click="closeHandel">
						X
					</view>
				 </view>
				 <view v-if="inviteStatu">
				 	<view class="input_name">Submit X post link</view>
				 	<view class="input_box">
				 		<input class="uni-input" focus v-model="changeValue1" />
				 	</view>
				 	<view class="input_name" style="color: rgba(189, 189, 189, 1);">X post username must match TG bot username </view>
				 	<button class="sbumit_bnt" size="default" type="default"
				 		hover-class="is-hover" @click="sbumitHandel">Send Link</button>
				 </view>
				 <view class="successful" v-else>
				 	<view class="successful_icon">
				 		<image src="/static/img/annotation-check.png" mode=""></image>
				 	</view>
					<view class="successful_title">Review in progress</view>
				 </view>
			</view>
		</uni-popup>
		<!-- Submit meme 弹窗 start -->
		<uni-popup
			width="100%"
			ref="namePopup"
			 background-color="#1B2025"
			 bottom
			 type="bottom"
			 borderRadius="10px 10px 0 0"
			 @change="change">
			<view class="popup-content">
				<view class="title">
				 	<view class="title_name">Submit meme</view>
					<view class="title_icon"  @click="$refs.namePopup.close()">X</view>
				</view>
				<view class="input_name">Submit X link with $DAWG meme</view>
				<view class="input_box">
					<input class="uni-input"  focus v-model="changeValue" />
				</view>
				<view class="input_name" style="color: rgba(189, 189, 189, 1);">X post username must match TG bot username </view>
				<button class="sbumit_bnt" size="default" type="default"
					hover-class="is-hover" @click="nameHandel">Submit</button>
			</view>
		</uni-popup>
		<!-- Daily Check In 弹窗 start -->
		<uni-popup
			width="100%"
			ref="signinPopup"
			 background-color="#1B2025"
			 bottom
			 type="bottom"
			 borderRadius="10px 10px 0 0"
			 @change="change">
			<view class="popup-content">
				 <view class="title">
				 	<view class="title_name">Daily Check In</view>
					<view class="title_icon"  @click="signInHandel">X</view>
				 </view>
				 <view class="input_name">Check in daily to collect your daily rewards</view>
				 <sign-in :cumulateDays="cumulateDays"></sign-in>
				 <button class="sbumit_bnt" size="default" type="default" hover-class="is-hover" @click="signInHandel">Claim</button>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import {request} from '@/api/api.js'
	import priceItem from '@/components/priceIte.vue'
	import tabsActive from '@/components/tabsActive.vue'
	import personInformation from '@/components/personInforma.vue'
	import signIn from '@/components/signIn.vue'
	import data from'@/static/data.js'
	export default {
		components:{
			priceItem,
			tabsActive,
			personInformation,
			signIn
		},
		data() {
			return {
				indexc: 0,
				changeValue:'',
				inviteStatu:true,
				priceList:data.priceList,
				pricedata:data.priceLists,
				cumulateDays:[],
				changeValue1:''
			}
		},
		onLoad() {
			this.signInGetData()
			this.signInConfiguredGetData()
		},
		mounted() {
			this.signrecord()
		},
		methods: {
			//获取签到记录
			async signrecord(){
				await request({url:'/signrecord/user',method:'GET'}).then(async res => {
					if(res.code == 200) {
						res.data.cumulateDays
						if(res.data.cumulateDays <= 0) {
							this.cumulateDays.push(res.data.cumulateDays)
							console.log('签到记录',JSON.stringify(this.cumulateDays))
							return
						}
						for(var i=0;i<res.data.cumulateDays;i++){
							this.cumulateDays.push(i+1)
						}
						console.log('签到记录',JSON.stringify(this.cumulateDays))
					}
				})
			},
			checkHandel(e,i){
				this.indexc = e
			},
			priceHandel(e){
				console.log(e)
				if(e == 7){
					this.$refs.popup.open();
				}else if(e == 8){
					this.$refs.namePopup.open();
				}else if(e == 4){
					this.$refs.signinPopup.open()
				}else if(e == 1){
					uni.navigateTo({
						url:'/pages/tgChatLink/index'
					})
				}else if(e == 2){
					uni.navigateTo({
						url:'/pages/tgChanneLink/index?url='+'https://t.me/dawgchannel/'
					})
				}else if(e == 9){
					this.$emit('AirdropIndex',2)
				}
				else if(e == 5) {
					uni.navigateTo({
						url:'/pages/tgChanneLink/index?url='+'https://x.com/dawgtokensol'
					})
				}
			},
			closeHandel(){
				this.$refs.popup.close(this.inviteStatu = true);
			},
			sbumitHandel(){
				
				request({url:'/postinfo/submit',method:'POST',data:{postContent:this.changeValue1}}).then(res => {
					if(res.code == 200){
						this.inviteStatu = false
						this.changeValue1 = ''
					}
				})
			},
			nameHandel(){
				request({url:'/meme/submit',method:'POST',data:{postContent:this.changeValue}}).then(res => {
					if(res.code == 200){
						this.$refs.namePopup.close();
						this.changeValue = ''
					}
				})
			},
			// 提交签到
			signInHandel(){
				this.$refs.signinPopup.close()
				request({url:'/signrecord/user',method: 'POST'}).then(res => {
					console.log('提交签到',res)
					if(res.code == 200) {
						this.signrecord()
					}
				})
			},
			// 签到配置列表接口
			signInConfiguredGetData(){
				uni.request({
				    url: 'http://open.zhimulp.online/jump/signrecord/user',// 你的API地址
					header:{
						'Authorization':"853004962065444bb0195f6c9ab57644"
					},
					method: 'GET',
				    success: (res) => {
				        console.error('GET请求成功：', err);
				    },
				    fail: (err) => {
				        console.error('GET请求失败：', err);
				    }
				});
			},
			// 签到记录接口
			signInGetData(){
				uni.request({
				    url: 'http://open.zhimulp.online/jump/signrecord/user',// 你的API地址
					header:{
						'Authorization':"853004962065444bb0195f6c9ab57644"
					},
					method: 'GET',
				    success: (res) => {
				        console.error('GET请求成功：', err);
				    },
				    fail: (err) => {
				        console.error('GET请求失败：', err);
				    }
				});
			},
			
		}
	}
</script>

<style lang="scss" scoped>
	input{
		color: #fff;
	}
	.content {
		width: 100vw;
		height: 90vh;
		background: #000;
		.popup-content{
			width: calc(100% - 40px);
			overflow: auto;
			margin: 0 auto;
			.successful{
				width: 100%;
				padding: 50px 0;
				.successful_icon{
					width: 100%;
					text-align: center;
					display: flex;
					justify-content: center;
					align-items: center;
					image{
						width: 24px;
						height: 24px;
						background-repeat: no-repeat;
						background-size: cover;
					}
				}
				.successful_title{
					width: 100%;
					height: 40px;
					line-height: 40px;
					text-align: center;
					font-family: Inter;
					font-size: 15px;
					font-weight: 500;
					color: #fff;
					letter-spacing: -0.4000000059604645px;
					text-align: center;

				}
			}
			.title{
				width: 100%;
				display: flex;
				justify-content: space-between;
				margin-bottom: 30px;
				.title_name{
					height: 28px;
					line-height: 28;
					color: #fff;
					line-height: 40px;
					padding: 10px 0;
					font-family: Inter;
					font-size: 26px;
					font-weight: 600;
					line-height: 40px;
					text-align: left;
		
				}
				.title_icon{
					width: 20px;
					height: 20px;
					margin: 20px 0;
					display: flex;
					justify-items: end;
					text-align: center;
					color: #fff;
				}
			}
			.input_name{
				width: 100%;
				color: #fff;
				font-family: Inter;
				font-size: 15px;
				font-weight: 500;
				line-height: 22px;
				letter-spacing: -0.4000000059604645px;
				text-align: left;
				margin: 0 0 10px 0;
			}
			
			.input_box{
				display: flex;
				justify-content: space-between;
				background-color:rgba(255, 255, 255, 0.16);
				border-radius: 5px;
				image{
					width: 20px;
					height: 20px;
					background-repeat: no-repeat;
					background-size: cover;
					margin-right: 12px;
					margin-top: 15px;
				}
				.uni-input{
					width: calc(100% - 20px);
					height: 40px;
					border-radius: 5px;
					padding:5px 10px;
					
				}
			}
			
			.sbumit_bnt{
				color: #000;
				background-color:  rgba(193, 227, 255, 1);
				border-color: rgba(193, 227, 255, 1);
				margin-bottom: 50px;
				margin-top: 50px;
				font-family: Inter;
				font-size: 17px;
				font-weight: 600;
				text-align: center;
		
			}
		}
	}
</style>
